﻿using RAP.Framework.Libary.DomTemplateBuilder;
using RAP.Framework.Libary.Utils;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;

namespace RAP.Framework.Libary.DataSource.Context
{
  /// <summary>
  /// 数据查询上下文对象
  /// </summary>
  public class DataServiceContext : TemplateRenderContext, IDataServiceContext
  {
    /// <summary>
    /// 
    /// </summary>
    public DataServiceContext( )
    {
      this[ ServiceUtils.RESULT_FIELD ] = this.ResultData;
    }

    /// <summary>
    /// 
    /// </summary>
    public IDictionary ResultData { get; private set; } = new ListDictionary();

    /// <summary>
    /// 
    /// </summary>
    public StepProgress Progress { get; } = new StepProgress();

    /// <summary>
    /// 
    /// </summary>
    public IDictionary CachedResult
    {
      get
      {
        return this.ToDictionary( nameof( CachedResult ) );
      }
    }

    /// <summary>
    /// 
    /// </summary>
    public bool Disposable { get; set; } = true;

    /// <summary>
    /// 
    /// </summary>
    public override void Dispose( )
    {
      base.Dispose();
      ResultData = null;
    }
  }
}
